package com.luyue.zagj.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.luyue.zagj.R;
import com.luyue.zagj.domin.News;

/**
 * Created by luyue on 2016/11/14.
 */

public class NewsViewHolder extends BaseViewHolder<News> {


    private TextView mTv_name;
    private ImageView mImg_face;
    private TextView mTv_sign;

    public NewsViewHolder(View itemView) {
        super(itemView);
    }

    public NewsViewHolder(ViewGroup parent) {
        super(parent, R.layout.news_recycler_item);
        mTv_name = $(R.id.person_name);
        mTv_sign = $(R.id.person_sign);
        mImg_face = $(R.id.person_face);
    }

    @Override
    public void setData(final News data) {
        int n= (int) (Math.random() * 3+1);
            switch (n){
                case 1:
                    mTv_name.setText("地点：西湖区文一路");
                    Glide.with(getContext())
                            .load(R.mipmap.drivingrecord)
                            .placeholder(R.mipmap.ic_launcher)
                            .centerCrop()
                            .into(mImg_face);
                    break;
                case 2:
                    mTv_name.setText("地点：萧山国际机场");
                    Glide.with(getContext())
                            .load(R.mipmap.warn)
                            .placeholder(R.mipmap.ic_launcher)
                            .centerCrop()
                            .into(mImg_face);
                    break;
                case 3:
                    mTv_name.setText("手动锁加锁");
                    Glide.with(getContext())
                            .load(R.mipmap.claims)
                            .placeholder(R.mipmap.ic_launcher)
                            .centerCrop()
                            .into(mImg_face);
                    break;
                default:
                    break;
            }


   //     mTv_name.setText(data.getTitle());



        mTv_sign.setText(data.getCtime());



//        Glide.with(getContext())
//                .load(data.getPicUrl())
//                .placeholder(R.mipmap.ic_launcher)
//                .centerCrop()
//                .into(mImg_face);
    }
}
